/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using DaveSexton.DocProject.Sandcastle.ContentManagement;
using DaveSexton.Controls;

namespace DaveSexton.DocProject.Sandcastle.TopicManagement
{
	public sealed class ConceptualTopicContentItem : ContentItem
	{
		#region Public Properties
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1802:UseLiteralsWhereAppropriate")]
		public static readonly string DefaultName = "ConceptualContentItem";

		public override string Value
		{
			get
			{
				return topic.XmlDocument;
			}
			set
			{
				topic.XmlDocument = value;

				if (Document != null)
					Document.NotifyItemChanged(this);
			}
		}

		public override bool IsDirty
		{
			get
			{
				return topic.IsDirty;
			}
			protected internal set
			{
				// do nothing since the topic item handles its own dirty state interally
			}
		}

		public override bool IsValueDesignable
		{
			get
			{
				return false;
			}
		}
		#endregion

		#region Private / Protected
		private readonly XmlConceptualTopic topic;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="ConceptualTopicContentItem" /> class.
		/// </summary>
		public ConceptualTopicContentItem(XmlConceptualTopic topic)
			: base(DefaultName, false)
		{
			if (topic == null)
				throw new ArgumentNullException("topic");

			this.topic = topic;
		}
		#endregion

		#region Methods
		public override string ToString()
		{
			return DefaultName;
		}

		public override bool Delete()
		{
			return false;
		}

		public void CommitChanges()
		{
			topic.CommitChanges();
		}

		public void CancelChanges()
		{
			topic.CancelChanges();
		}
		#endregion
	}
}
